package main.java.com.yc.navy.snacknet.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yc.navy.snacknet.bean.TypeInfo;
import com.yc.navy.snacknet.enums.ResultEnum;
import com.yc.navy.snacknet.mapper.ITypeInfoMapper;
import com.yc.navy.snacknet.service.ITypeInfoService;
import com.yc.navy.snacknet.util.FindByPageParamUtil;
import com.yc.navy.snacknet.util.StringUtil;
import com.yc.navy.snacknet.vo.LayuiVO;

@Service
public class TypeInfoServiceImpl implements ITypeInfoService{
	@Autowired
	private ITypeInfoMapper typeInfoMapper ;
	@Override
	public LayuiVO firstFind(Map<String, Object> map) {
		List<TypeInfo> list = typeInfoMapper.findByPage(FindByPageParamUtil.layuiFindByPage(map));
		if(list == null || list.isEmpty()) {
			return new LayuiVO(ResultEnum.DATA_NULL);
		}
		return new LayuiVO(typeInfoMapper.total(map), list);
	}
	
	@Override
	public int add(TypeInfo tf) {
		if(StringUtil.checkNull(tf.getTname(), tf.getPic())) {
			return -100;
		}
		return typeInfoMapper.add(tf);
	}

	@Override
	public List<TypeInfo> finds() {
		return typeInfoMapper.finds();
	}

//	@Override
//	public List<TypeInfo> findtname() {
//		return typeInfoMapper.findtname();
//	}
//	
}
